﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        // Make FUnction For a Word Count
        private void button1_Click(object sender, EventArgs e)
        {

            string str = txtb1.Text;

            string[] InputDots;
            string[] InputSpaces;
            int WordCount;

            int Words = 0;
            int TempCount = 0;

            InputDots = str.Split('.');

            foreach (string strElement in InputDots)
            {
                TempCount += 1;

                InputSpaces = strElement.Split(' ');
                WordCount = InputSpaces.Length;

                Words += WordCount;
                if (TempCount == 2)
                {
                    WordCount -= 1;
                    Words -= 1;
                }

                lbl1.Text = WordCount.ToString();
            }

        }


        //Dierect Display character length in Lable

        private void btn2_Click(object sender, EventArgs e)
        {
            lbl2.Text = " char " + txtb2.Text.Trim().Length;
             
        }


        int spacecount(string value)
        {
            string text = " ";
            return value.Count(chr => (text.Contains(char.ToLowerInvariant(chr))));
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            lbl3.Text = spacecount(textBox1.Text).ToString();
        }
        /*
         This function counts the numeric values in the string passed
         * @params : value
         */
        int numbercount(string value)
        {
            string text = "0123456789";
            return value.Count(chr => (text.Contains(char.ToLowerInvariant(chr))));
        }

        private void btn4_Click(object sender, EventArgs e)
        {
            lbl4.Text = numbercount(txtb4.Text).ToString();
        }
    }
}